﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace nr.Windows.Controls
{
    public partial class TristateStatusFlag : UserControl
    {
        public enum TristateFlag
        {
            Red, Yellow, Green
        }

        private TristateFlag flag;

        public TristateFlag Flag
        {
            get { return flag; }
            set
            {
                flag = value;
                Invalidate();
            }
        }

        public TristateStatusFlag()
        {
            flag = TristateFlag.Red;
            InitializeComponent();
        }

        private void TristateStatusFlag_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(BackColor);
            Color[] colors = { Color.Red, Color.Yellow, Color.Green };
            Rectangle rect = new Rectangle(Margin.Left, Margin.Top, Size.Width - Margin.Left - Margin.Right, Size.Height - Margin.Top - Margin.Bottom);
            e.Graphics.FillEllipse(new SolidBrush(colors[(int)Flag]), rect);
            e.Graphics.DrawEllipse(new Pen(Brushes.Black, 2), rect);
        }
    }
}
